home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / splitpat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.3 KB  |  62 lines

  1. /*
  2.     splitpath.c pwp 93 07 14
  3.     replacement function for _splitpath
  4.     for NON-MSDOS systems ONLY
  5.  
  6.     Parameters:
  7.         path:   source path to be split
  8.  
  9.     The drive, dir fname, ext parameters are buffers provided by the
  10.         caller; they should be large enough; this is NOT checked
  11.  
  12.         drive:  drive part of path, will be set to empty string
  13.         dir:    directory part of path;
  14.                 if found, contains the leading DIRSEP
  15.         fname:  the base file name without extensions
  16.         ext:    the extension, if any, including the
  17.                 leading period
  18. */
  19. #ifndef MSDOS
  20.  
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include "icrss.h"
  24.  
  25. void _splitpath(const char * path,
  26.     char * drive, char * dir, char * fname, char * ext)
  27. {
  28.  
  29.     char
  30.         * p;
  31.  
  32.     drive[0] = '\x0';
  33.  
  34.     if ( (p = strrchr(path, DIRSEP)) )
  35.     {
  36.         char
  37.             fname_first;
  38.  
  39.         fname_first = *(++p);
  40.         *p = '\x0';
  41.         strcpy(dir, path);
  42.         *p = fname_first;
  43.         path = p;               /*  path now points to filename part    */
  44.     }
  45.     else
  46.         dir[0] = '\x0';
  47.  
  48.     if ( (p = strrchr(path, '.')) )
  49.     {
  50.         *p = '\x0';
  51.         strcpy(fname, path);
  52.         *p = '.';
  53.         strcpy(ext, p);
  54.     }
  55.     else
  56.     {
  57.         strcpy(fname, path);
  58.         ext[0] = '\x0';
  59.     }
  60. }
  61. #endif
  62.